package day01;

import org.junit.Test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class JDBCutils {


    public static Connection getConnection() throws ClassNotFoundException, SQLException {
//加载驱动
        Class.forName("com.mysql.jdbc.Driver");
//
        String url = "jdbc:mysql://127.0.0.1:3306/mysql_db?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai";
        String userName = "root";
        String passWord = "root";
//        获取数据库连接
        Connection connection = DriverManager.getConnection(url, userName, passWord);
        System.out.println("connection=" + connection);
        return connection;
    }
}
